package cc.sbootd2.sbootd2web.interceptor;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;



@Component("sysInterceptor")
public class SysInterceptor extends HandlerInterceptorAdapter {
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws
            Exception {

       if(request.getSession().getAttribute("loginUser")!=null){
           return true;
       }


       response.sendRedirect(request.getContextPath()+"/admin/login.jsp");
        return false;
    }
}
